templateViewInit = ()=>{
    workdbFieldConvert(document.querySelectorAll('.layui-form .dict-module'));
    form.render(null, 'user-setting');
    form.val('user-setting', top.tools.cache.getUser());
    top.tools.file().downloadFile({
        elem:$('.jmAvatar'),
        avatar:top.tools.cache.getUser().avatar
    })

}

function update(type){
    switch (type){
        case 'password':
            openForm({
                title:"重置密码",
                btn:1,
                save:(closeid)=>{
                    let formData = top.tools.form.getFindElementOnObj("#lay-reset-password-form",true);
                    formData.id = top.tools.cache.getUser().id;
                    top.API.user().updatePassword(formData,(res)=>{
                        layer.msg(res.message, {icon: 1});
                        if (closeid){
                            layer.close(closeid);
                        }
                    })
                },
                reset:(closeid)=>{
                    form.val('reset-password-form', top.tools.form.getFindElementOnObj("#lay-reset-password-form",false));
                },
                area:'20%',
                before:(closeid)=>{

                }
            },'reset-password-form')
            break;
        case 'mobile':
            openForm({
                title:"重置手机号",
                btn:1,
                save:(closeid)=>{
                    let formData = top.tools.form.getFindElementOnObj("#lay-reset-mobile-form",true);
                    formData.id = top.tools.cache.getUser().id;
                    top.API.user().updatePassword(formData,(res)=>{
                        layer.msg(res.message, {icon: 1});
                        if (closeid){
                            layer.close(closeid);
                        }
                    })
                },
                reset:(closeid)=>{
                    form.val('reset-mobile-form', top.tools.form.getFindElementOnObj("#lay-reset-mobile-form",false));
                },
                area:'25%',
                before:(closeid)=>{
                    // 普通事件
                    util.on('lay-on', {
                        // 获取验证码
                        "get-vercode": function(othis){
                            var isvalid = form.validate($('#lay-reset-mobile-form input[name=mobile]')); // 主动触发验证，v2.7.0 新增
                            // 验证通过
                            if(isvalid){
                                layer.msg('手机号规则验证通过');
                            }
                        }
                    });
                }
            },'reset-mobile-form')
            break;
        case 'email':
            openForm({
                title:"重置邮箱",
                btn:1,
                save:(closeid)=>{
                    let formData = top.tools.form.getFindElementOnObj("#lay-reset-email-form",true);
                    formData.id = top.tools.cache.getUser().id;
                    top.API.user().updatePassword(formData,(res)=>{
                        layer.msg(res.message, {icon: 1});
                        if (closeid){
                            layer.close(closeid);
                        }
                    })
                },
                reset:(closeid)=>{
                    form.val('reset-email-form', top.tools.form.getFindElementOnObj("#lay-reset-email-form",false));
                },
                area:'25%',
                before:(closeid)=>{
                    // 普通事件
                    util.on('lay-on', {
                        // 获取验证码
                        "get-vercode": function(othis){
                            var isvalid = form.validate($('#lay-reset-mobile-form input[name=email]')); // 主动触发验证，v2.7.0 新增
                            // 验证通过
                            if(isvalid){
                                layer.msg('email规则验证通过');
                            }
                        }
                    });
                }
            },'reset-email-form')
            break;
    }
}